package com.springmvc.converter;

import com.springmvc.entity.User;
import org.springframework.core.convert.converter.Converter;

public class UserConverter implements Converter<String, User> {
    @Override
    public User convert(String source) {
        // 前台传值 source:id,用户名,密码,身高
        String[] arr = source.split(",");

        User user = new User();
        user.setId(Long.parseLong(arr[0]));
        user.setUserName(arr[1]);
        user.setPassword(arr[2]);
        user.setHeight(Double.parseDouble(arr[3]));

        return user;
    }
}
